package com.yiren.manager.service.impl.department;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yiren.core.exception.MyException;
import com.yiren.core.service.GenericServiceImpl;
import com.yiren.core.utils.Favorites;
import com.yiren.entity.YrCgSendOrder;
import com.yiren.entity.YrCgsosSalaryDay;
import com.yiren.entity.YrElderArrearage;
import com.yiren.entity.YrElderPayRecord;
import com.yiren.entity.YrElderWallet;
import com.yiren.manager.repository.cost.YrCgsosSalaryDayRepository;
import com.yiren.manager.repository.cost.YrElderArrearageRepository;
import com.yiren.manager.repository.cost.YrElderPayRecordRepository;
import com.yiren.manager.repository.department.YrCgSendOrderRepository;
import com.yiren.manager.repository.elder.YrElderWalletRepository;
import com.yiren.manager.service.iface.department.YrCgSendOrderService;

@Service
public class YrCgSendOrderServiceImpl extends GenericServiceImpl<YrCgSendOrder, String> implements YrCgSendOrderService{

	@Autowired
	private YrElderArrearageRepository elderArrearageRepository;
	
	@Autowired
	private YrElderWalletRepository elderWalletRepository;
	
	@Autowired
	private YrElderPayRecordRepository elderPayRecordRepository;
	
	@Autowired
	private YrCgsosSalaryDayRepository cgsosSalaryDayRepository;
	
	@Autowired
	public YrCgSendOrderServiceImpl(YrCgSendOrderRepository repository) {
		super(repository);
	}

	@Transactional
	public void executefinish(Favorites entitys) throws MyException {
		YrCgSendOrder entity = entitys.getFavorite(YrCgSendOrder.class);
//		YrElderWallet elderWallet = entitys.getFavorite(YrElderWallet.class);
//		YrElderArrearage elderArrearage = entitys.getFavorite(YrElderArrearage.class);
//		YrIndiServiceCostRecord indiServiceCostRecord = entitys.getFavorite(YrIndiServiceCostRecord.class);
//		YrElderPayRecord elderPayRecord = entitys.getFavorite(YrElderPayRecord.class);
		YrCgsosSalaryDay cgsosSalaryDay = entitys.getFavorite(YrCgsosSalaryDay.class);
		
		this.repository.save(entity);
//		elderWalletRepository.save(elderWallet);
//		if(null!= elderArrearage){
//			elderArrearageRepository.save(elderArrearage);
//		}
//		if(null!=elderPayRecord){
//			elderPayRecordRepository.save(elderPayRecord);
//		}
		if(null!=cgsosSalaryDay){
			cgsosSalaryDayRepository.save(cgsosSalaryDay);
		}
	}

}
